<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      input {
        width: 150px;
        height: 30px;
        font-size: 16px;
        line-height: 30px;
        padding-left: 10px;
        margin-right: 20px;
      }
      button {
        height: 25px;
        width: 50px;
        font-size: 14px;
        line-height: 25px;
        text-align: center;
        border-radius: 5px;
        color: cornflowerblue;
      }
    </style>
  </head>

  <body>
    <input type="text" name="" id="height" placeholder="请输入身高" />
    <input type="text" name="" id="weight" placeholder="请输入体重" />
    <button id="btn">查询</button>

    <script>
      var h_Ele = document.getElementById("height");
      var w_Ele = document.getElementById("weight");
      //获取身高体重框的数据节点（document.getElementById返回值是一个数据节点（也可以说是对象））
      btn.onclick = function () //btn被点击之后执行函数
      {
        var myheight = parseInt(h_Ele.value);
        var myweight = parseInt(w_Ele.value);
        var res = (myheight - 108) * 2;
        console.log(res);
        var max = res + 10;
        var min = res - 10;
        if (myweight <= max && myweight >= min) {
          document.write("是标准体重");
        } else if (myweight < min) {
          document.write("太瘦了");
        } else {
          document.write("太胖了");
        }
      };
    </script>
  </body>
</html>
